{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import mai\n",
    "import torch"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "model = mai.models.detection.retinanet.resnet18(num_classes=8).cuda()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "focalloss = mai.losses.FocalLoss()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "output = model(torch.rand(1, 3, 224, 224).cuda())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[tensor([[[0.0100, 0.0100, 0.0100,  ..., 0.0100, 0.0100, 0.0100],\n",
       "          [0.0100, 0.0100, 0.0100,  ..., 0.0100, 0.0100, 0.0100],\n",
       "          [0.0100, 0.0100, 0.0100,  ..., 0.0100, 0.0100, 0.0100],\n",
       "          ...,\n",
       "          [0.0100, 0.0100, 0.0100,  ..., 0.0100, 0.0100, 0.0100],\n",
       "          [0.0100, 0.0100, 0.0100,  ..., 0.0100, 0.0100, 0.0100],\n",
       "          [0.0100, 0.0100, 0.0100,  ..., 0.0100, 0.0100, 0.0100]]],\n",
       "        device='cuda:0', grad_fn=<CatBackward>), tensor([[[0., 0., 0., 0.],\n",
       "          [0., 0., 0., 0.],\n",
       "          [0., 0., 0., 0.],\n",
       "          ...,\n",
       "          [0., 0., 0., 0.],\n",
       "          [0., 0., 0., 0.],\n",
       "          [0., 0., 0., 0.]]], device='cuda:0', grad_fn=<CatBackward>), tensor([[[ -18.6274,   -7.3137,   26.6274,   15.3137],\n",
       "          [ -24.5088,  -10.2544,   32.5088,   18.2544],\n",
       "          [ -31.9188,  -13.9594,   39.9188,   21.9594],\n",
       "          ...,\n",
       "          [  10.9807, -170.0387,  373.0193,  554.0387],\n",
       "          [ -36.0701, -264.1401,  420.0701,  648.1401],\n",
       "          [ -95.3503, -382.7006,  479.3503,  766.7006]]], device='cuda:0')]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "output"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(tensor([0.0569], device='cuda:0', grad_fn=<MeanBackward1>),\n",
       " tensor([0.], device='cuda:0'))"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "focalloss(output, torch.Tensor([[[279.2000,  37.6000, 758.4000, 576.0000,   0.0000]]]).cuda())"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.5"
  },
  "latex_envs": {
   "LaTeX_envs_menu_present": true,
   "autoclose": false,
   "autocomplete": true,
   "bibliofile": "biblio.bib",
   "cite_by": "apalike",
   "current_citInitial": 1,
   "eqLabelWithNumbers": true,
   "eqNumInitial": 1,
   "hotkeys": {
    "equation": "Ctrl-E",
    "itemize": "Ctrl-I"
   },
   "labels_anchors": false,
   "latex_user_defs": false,
   "report_style_numbering": false,
   "user_envs_cfg": false
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
